
using OhioState.AssetManaged;
using OhioState.Graphics;
using OhioState.Graphics.Proxy;

namespace OhioState.Graphics.OpenGL
{
    public class BoxOutlineHandler : OpenGLObject, IDrawable
    {
        public IMaterial Material
        {
            get { return boxProxy.Material; }
            set {}
        }
        public IBoundingVolume BoundingVolume
        {
            get { return boxProxy.BoundingVolume; }
        }
        public int DrawablePosition
        {
            get { return realBoxOutline.DrawablePosition; }
            set { realBoxOutline.DrawablePosition = value; }
        }
       
        public BoxOutlineHandler(BoxOutlineProxy proxyObj)
            : base(proxyObj)
        {
            boxProxy = proxyObj;
            realBoxOutline = new BoxOutlineGL(boxProxy.BoundingVolume as BoundingBox);
        }
        public void Render(IRenderPanel panel)
        {
            Update(panel);
            realBoxOutline.Render(panel);
        }

        public override void Update(IRenderPanel panel)
        {
            if (this.Invalid)
            {
                this.Invalid = false;
                realBoxOutline.DrawBackEdges = boxProxy.DrawBackEdges;
                realBoxOutline.DrawFrontEdges = boxProxy.DrawFrontEdges;
                realBoxOutline.BoundingVolume = boxProxy.BoundingVolume;
                realBoxOutline.Material = panel.ResourceManager.GetItem(boxProxy.Material as IAssetManaged) as IMaterial;
            }
        }

        private BoxOutlineProxy boxProxy;
        private BoxOutlineGL realBoxOutline;
    }
}
